package com.itheima.dao;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {
    @Insert("insert into user values (null, #{loginname}, #{password}, #{email}, #{nickname}, #{avatar}, #{createtime}, #{identity})")
    int save(User user);

    @Update("update user set password = #{password}, avatar = #{avatar},  nickname = #{nickname}  where uid = #{uid}")
    int update(User user);

    @Delete("delete from user where uid = #{uid}")
    int delete(Integer uid);

    @Select("select * from user where uid = #{uid}")
    User getById(Integer uid);

    @Select("select * from user where loginname = #{loginname}")
    User getByloginname(String loginname);

    @Select("select * from user ")
    List<User> getAll();
    @Select("select * from user where loginname = #{loginname} and identity =#{identity}")
    User getByloginname1(@Param("loginname") String loginname, @Param("identity")Integer identity);

    @Select("select * from user WHERE loginname LIKE CONCAT('%',#{loginname},'%')")
    List<User> selectAlluser(String loginname);

    @Update("update user set identity = #{temp}  where uid = #{uid}")
    int limit(@Param("uid")int uid, @Param("temp")int temp);

    @Select("select identity from user where uid = #{uid}")
    int getIdentity(int uid);

    @Update("update user set email = #{email},  nickname = #{nickname}  where uid = #{uid}")
    int homeUpdate(User user);
}
